package com.PlantVsZombies.online;

import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;

public class DataReceive implements Runnable{

	private Socket socket;
	
	public DataReceive(Socket socket) {
		super();
		this.socket = socket;
	}

	@Override
	public void run() {
		while (true) {
			try {
				InputStream is = socket.getInputStream();
				ObjectInputStream ois = new ObjectInputStream(is);
				Object object = ois.readObject();
				System.out.println(object);
				if (object instanceof ArrayList) {
					List list = (ArrayList)object;
					System.out.println(list.get(0));
				}
			} catch (IOException e) {
				System.out.println("服务器断开了连接");
				return;
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		}
	}

}
